package o;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import android.view.ViewPropertyAnimator;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView.s;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class me extends mt {
    private static TimeInterpolator ॱॱ;
    private ArrayList<s> ʼ = new ArrayList();
    ArrayList<s> ʽ = new ArrayList();
    ArrayList<s> ˊ = new ArrayList();
    ArrayList<ArrayList<s>> ˋ = new ArrayList();
    private ArrayList<a> ˋॱ = new ArrayList();
    ArrayList<ArrayList<a>> ˎ = new ArrayList();
    ArrayList<ArrayList<c>> ˏ = new ArrayList();
    private ArrayList<s> ͺ = new ArrayList();
    ArrayList<s> ॱ = new ArrayList();
    private ArrayList<c> ॱˊ = new ArrayList();
    ArrayList<s> ᐝ = new ArrayList();

    static class a {
        public int ˊ;
        public int ˋ;
        public int ˎ;
        public int ˏ;
        public s ॱ;

        a(s sVar, int i, int i2, int i3, int i4) {
            this.ॱ = sVar;
            this.ˊ = i;
            this.ˋ = i2;
            this.ˏ = i3;
            this.ˎ = i4;
        }
    }

    static class c {
        public s ˊ;
        public int ˋ;
        public s ˎ;
        public int ˏ;
        public int ॱ;
        public int ॱॱ;

        private c(s sVar, s sVar2) {
            this.ˊ = sVar;
            this.ˎ = sVar2;
        }

        c(s sVar, s sVar2, int i, int i2, int i3, int i4) {
            this(sVar, sVar2);
            this.ॱ = i;
            this.ˏ = i2;
            this.ˋ = i3;
            this.ॱॱ = i4;
        }

        public String toString() {
            return "ChangeInfo{oldHolder=" + this.ˊ + ", newHolder=" + this.ˎ + ", fromX=" + this.ॱ + ", fromY=" + this.ˏ + ", toX=" + this.ˋ + ", toY=" + this.ॱॱ + '}';
        }
    }

    public void ˋ() {
        int i;
        int i2;
        int i3;
        int i4 = !this.ʼ.isEmpty() ? 1 : 0;
        if (this.ˋॱ.isEmpty()) {
            i = 0;
        } else {
            i = 1;
        }
        if (this.ॱˊ.isEmpty()) {
            i2 = 0;
        } else {
            i2 = 1;
        }
        if (this.ͺ.isEmpty()) {
            i3 = 0;
        } else {
            i3 = 1;
        }
        if (i4 != 0 || i != 0 || i3 != 0 || i2 != 0) {
            final ArrayList arrayList;
            Runnable anonymousClass1;
            Iterator it = this.ʼ.iterator();
            while (it.hasNext()) {
                ˈ((s) it.next());
            }
            this.ʼ.clear();
            if (i != 0) {
                arrayList = new ArrayList();
                arrayList.addAll(this.ˋॱ);
                this.ˎ.add(arrayList);
                this.ˋॱ.clear();
                anonymousClass1 = new Runnable(this) {
                    final /* synthetic */ me ॱ;

                    public void run() {
                        Iterator it = arrayList.iterator();
                        while (it.hasNext()) {
                            a aVar = (a) it.next();
                            this.ॱ.ˋ(aVar.ॱ, aVar.ˊ, aVar.ˋ, aVar.ˏ, aVar.ˎ);
                        }
                        arrayList.clear();
                        this.ॱ.ˎ.remove(arrayList);
                    }
                };
                if (i4 != 0) {
                    ViewCompat.ˏ(((a) arrayList.get(0)).ॱ.ˊ, anonymousClass1, ʼ());
                } else {
                    anonymousClass1.run();
                }
            }
            if (i2 != 0) {
                arrayList = new ArrayList();
                arrayList.addAll(this.ॱˊ);
                this.ˏ.add(arrayList);
                this.ॱˊ.clear();
                anonymousClass1 = new Runnable(this) {
                    final /* synthetic */ me ˎ;

                    public void run() {
                        Iterator it = arrayList.iterator();
                        while (it.hasNext()) {
                            this.ˎ.ˋ((c) it.next());
                        }
                        arrayList.clear();
                        this.ˎ.ˏ.remove(arrayList);
                    }
                };
                if (i4 != 0) {
                    ViewCompat.ˏ(((c) arrayList.get(0)).ˊ.ˊ, anonymousClass1, ʼ());
                } else {
                    anonymousClass1.run();
                }
            }
            if (i3 != 0) {
                final ArrayList arrayList2 = new ArrayList();
                arrayList2.addAll(this.ͺ);
                this.ˋ.add(arrayList2);
                this.ͺ.clear();
                Runnable anonymousClass2 = new Runnable(this) {
                    final /* synthetic */ me ˋ;

                    public void run() {
                        Iterator it = arrayList2.iterator();
                        while (it.hasNext()) {
                            this.ˋ.ॱ((s) it.next());
                        }
                        arrayList2.clear();
                        this.ˋ.ˋ.remove(arrayList2);
                    }
                };
                if (i4 == 0 && i == 0 && i2 == 0) {
                    anonymousClass2.run();
                    return;
                }
                long ˎ;
                long ॱॱ;
                long ʼ = i4 != 0 ? ʼ() : 0;
                if (i != 0) {
                    ˎ = ˎ();
                } else {
                    ˎ = 0;
                }
                if (i2 != 0) {
                    ॱॱ = ॱॱ();
                } else {
                    ॱॱ = 0;
                }
                ViewCompat.ˏ(((s) arrayList2.get(0)).ˊ, anonymousClass2, ʼ + Math.max(ˎ, ॱॱ));
            }
        }
    }

    public boolean ˎ(s sVar) {
        ʼॱ(sVar);
        this.ʼ.add(sVar);
        return true;
    }

    private void ˈ(final s sVar) {
        final View view = sVar.ˊ;
        final ViewPropertyAnimator animate = view.animate();
        this.ᐝ.add(sVar);
        animate.setDuration(ʼ()).alpha(0.0f).setListener(new AnimatorListenerAdapter(this) {
            final /* synthetic */ me ˊ;

            public void onAnimationStart(Animator animator) {
                this.ˊ.ˋॱ(sVar);
            }

            public void onAnimationEnd(Animator animator) {
                animate.setListener(null);
                view.setAlpha(1.0f);
                this.ˊ.ʻ(sVar);
                this.ˊ.ᐝ.remove(sVar);
                this.ˊ.ˊ();
            }
        }).start();
    }

    public boolean ˋ(s sVar) {
        ʼॱ(sVar);
        sVar.ˊ.setAlpha(0.0f);
        this.ͺ.add(sVar);
        return true;
    }

    void ॱ(final s sVar) {
        final View view = sVar.ˊ;
        final ViewPropertyAnimator animate = view.animate();
        this.ॱ.add(sVar);
        animate.alpha(1.0f).setDuration(ʽ()).setListener(new AnimatorListenerAdapter(this) {
            final /* synthetic */ me ˊ;

            public void onAnimationStart(Animator animator) {
                this.ˊ.ˏॱ(sVar);
            }

            public void onAnimationCancel(Animator animator) {
                view.setAlpha(1.0f);
            }

            public void onAnimationEnd(Animator animator) {
                animate.setListener(null);
                this.ˊ.ॱˊ(sVar);
                this.ˊ.ॱ.remove(sVar);
                this.ˊ.ˊ();
            }
        }).start();
    }

    public boolean ˏ(s sVar, int i, int i2, int i3, int i4) {
        View view = sVar.ˊ;
        int translationX = i + ((int) sVar.ˊ.getTranslationX());
        int translationY = i2 + ((int) sVar.ˊ.getTranslationY());
        ʼॱ(sVar);
        int i5 = i3 - translationX;
        int i6 = i4 - translationY;
        if (i5 == 0 && i6 == 0) {
            ʼ(sVar);
            return false;
        }
        if (i5 != 0) {
            view.setTranslationX((float) (-i5));
        }
        if (i6 != 0) {
            view.setTranslationY((float) (-i6));
        }
        this.ˋॱ.add(new a(sVar, translationX, translationY, i3, i4));
        return true;
    }

    void ˋ(s sVar, int i, int i2, int i3, int i4) {
        final View view = sVar.ˊ;
        final int i5 = i3 - i;
        final int i6 = i4 - i2;
        if (i5 != 0) {
            view.animate().translationX(0.0f);
        }
        if (i6 != 0) {
            view.animate().translationY(0.0f);
        }
        final ViewPropertyAnimator animate = view.animate();
        this.ˊ.add(sVar);
        final s sVar2 = sVar;
        animate.setDuration(ˎ()).setListener(new AnimatorListenerAdapter(this) {
            final /* synthetic */ me ʻ;

            public void onAnimationStart(Animator animator) {
                this.ʻ.ˊॱ(sVar2);
            }

            public void onAnimationCancel(Animator animator) {
                if (i5 != 0) {
                    view.setTranslationX(0.0f);
                }
                if (i6 != 0) {
                    view.setTranslationY(0.0f);
                }
            }

            public void onAnimationEnd(Animator animator) {
                animate.setListener(null);
                this.ʻ.ʼ(sVar2);
                this.ʻ.ˊ.remove(sVar2);
                this.ʻ.ˊ();
            }
        }).start();
    }

    public boolean ˏ(s sVar, s sVar2, int i, int i2, int i3, int i4) {
        if (sVar == sVar2) {
            return ˏ(sVar, i, i2, i3, i4);
        }
        float translationX = sVar.ˊ.getTranslationX();
        float translationY = sVar.ˊ.getTranslationY();
        float alpha = sVar.ˊ.getAlpha();
        ʼॱ(sVar);
        int i5 = (int) (((float) (i3 - i)) - translationX);
        int i6 = (int) (((float) (i4 - i2)) - translationY);
        sVar.ˊ.setTranslationX(translationX);
        sVar.ˊ.setTranslationY(translationY);
        sVar.ˊ.setAlpha(alpha);
        if (sVar2 != null) {
            ʼॱ(sVar2);
            sVar2.ˊ.setTranslationX((float) (-i5));
            sVar2.ˊ.setTranslationY((float) (-i6));
            sVar2.ˊ.setAlpha(0.0f);
        }
        this.ॱˊ.add(new c(sVar, sVar2, i, i2, i3, i4));
        return true;
    }

    void ˋ(final c cVar) {
        View view = null;
        s sVar = cVar.ˊ;
        final View view2 = sVar == null ? null : sVar.ˊ;
        s sVar2 = cVar.ˎ;
        if (sVar2 != null) {
            view = sVar2.ˊ;
        }
        if (view2 != null) {
            final ViewPropertyAnimator duration = view2.animate().setDuration(ॱॱ());
            this.ʽ.add(cVar.ˊ);
            duration.translationX((float) (cVar.ˋ - cVar.ॱ));
            duration.translationY((float) (cVar.ॱॱ - cVar.ˏ));
            duration.alpha(0.0f).setListener(new AnimatorListenerAdapter(this) {
                final /* synthetic */ me ˎ;

                public void onAnimationStart(Animator animator) {
                    this.ˎ.ˊ(cVar.ˊ, true);
                }

                public void onAnimationEnd(Animator animator) {
                    duration.setListener(null);
                    view2.setAlpha(1.0f);
                    view2.setTranslationX(0.0f);
                    view2.setTranslationY(0.0f);
                    this.ˎ.ॱ(cVar.ˊ, true);
                    this.ˎ.ʽ.remove(cVar.ˊ);
                    this.ˎ.ˊ();
                }
            }).start();
        }
        if (view != null) {
            final ViewPropertyAnimator animate = view.animate();
            this.ʽ.add(cVar.ˎ);
            animate.translationX(0.0f).translationY(0.0f).setDuration(ॱॱ()).alpha(1.0f).setListener(new AnimatorListenerAdapter(this) {
                final /* synthetic */ me ˏ;

                public void onAnimationStart(Animator animator) {
                    this.ˏ.ˊ(cVar.ˎ, false);
                }

                public void onAnimationEnd(Animator animator) {
                    animate.setListener(null);
                    view.setAlpha(1.0f);
                    view.setTranslationX(0.0f);
                    view.setTranslationY(0.0f);
                    this.ˏ.ॱ(cVar.ˎ, false);
                    this.ˏ.ʽ.remove(cVar.ˎ);
                    this.ˏ.ˊ();
                }
            }).start();
        }
    }

    private void ˏ(List<c> list, s sVar) {
        for (int size = list.size() - 1; size >= 0; size--) {
            c cVar = (c) list.get(size);
            if (ˎ(cVar, sVar) && cVar.ˊ == null && cVar.ˎ == null) {
                list.remove(cVar);
            }
        }
    }

    private void ˊ(c cVar) {
        if (cVar.ˊ != null) {
            ˎ(cVar, cVar.ˊ);
        }
        if (cVar.ˎ != null) {
            ˎ(cVar, cVar.ˎ);
        }
    }

    private boolean ˎ(c cVar, s sVar) {
        boolean z = false;
        if (cVar.ˎ == sVar) {
            cVar.ˎ = null;
        } else if (cVar.ˊ != sVar) {
            return false;
        } else {
            cVar.ˊ = null;
            z = true;
        }
        sVar.ˊ.setAlpha(1.0f);
        sVar.ˊ.setTranslationX(0.0f);
        sVar.ˊ.setTranslationY(0.0f);
        ॱ(sVar, z);
        return true;
    }

    public void ˊ(s sVar) {
        int size;
        View view = sVar.ˊ;
        view.animate().cancel();
        for (size = this.ˋॱ.size() - 1; size >= 0; size--) {
            if (((a) this.ˋॱ.get(size)).ॱ == sVar) {
                view.setTranslationY(0.0f);
                view.setTranslationX(0.0f);
                ʼ(sVar);
                this.ˋॱ.remove(size);
            }
        }
        ˏ(this.ॱˊ, sVar);
        if (this.ʼ.remove(sVar)) {
            view.setAlpha(1.0f);
            ʻ(sVar);
        }
        if (this.ͺ.remove(sVar)) {
            view.setAlpha(1.0f);
            ॱˊ(sVar);
        }
        for (size = this.ˏ.size() - 1; size >= 0; size--) {
            ArrayList arrayList = (ArrayList) this.ˏ.get(size);
            ˏ(arrayList, sVar);
            if (arrayList.isEmpty()) {
                this.ˏ.remove(size);
            }
        }
        for (int size2 = this.ˎ.size() - 1; size2 >= 0; size2--) {
            arrayList = (ArrayList) this.ˎ.get(size2);
            int size3 = arrayList.size() - 1;
            while (size3 >= 0) {
                if (((a) arrayList.get(size3)).ॱ == sVar) {
                    view.setTranslationY(0.0f);
                    view.setTranslationX(0.0f);
                    ʼ(sVar);
                    arrayList.remove(size3);
                    if (arrayList.isEmpty()) {
                        this.ˎ.remove(size2);
                    }
                } else {
                    size3--;
                }
            }
        }
        for (size = this.ˋ.size() - 1; size >= 0; size--) {
            arrayList = (ArrayList) this.ˋ.get(size);
            if (arrayList.remove(sVar)) {
                view.setAlpha(1.0f);
                ॱˊ(sVar);
                if (arrayList.isEmpty()) {
                    this.ˋ.remove(size);
                }
            }
        }
        if (this.ᐝ.remove(sVar)) {
        }
        if (this.ॱ.remove(sVar)) {
        }
        if (this.ʽ.remove(sVar)) {
        }
        if (this.ˊ.remove(sVar)) {
            ˊ();
        } else {
            ˊ();
        }
    }

    private void ʼॱ(s sVar) {
        if (ॱॱ == null) {
            ॱॱ = new ValueAnimator().getInterpolator();
        }
        sVar.ˊ.animate().setInterpolator(ॱॱ);
        ˊ(sVar);
    }

    public boolean ॱ() {
        return (this.ͺ.isEmpty() && this.ॱˊ.isEmpty() && this.ˋॱ.isEmpty() && this.ʼ.isEmpty() && this.ˊ.isEmpty() && this.ᐝ.isEmpty() && this.ॱ.isEmpty() && this.ʽ.isEmpty() && this.ˎ.isEmpty() && this.ˋ.isEmpty() && this.ˏ.isEmpty()) ? false : true;
    }

    void ˊ() {
        if (!ॱ()) {
            ᐝ();
        }
    }

    public void ˏ() {
        int size;
        for (size = this.ˋॱ.size() - 1; size >= 0; size--) {
            a aVar = (a) this.ˋॱ.get(size);
            View view = aVar.ॱ.ˊ;
            view.setTranslationY(0.0f);
            view.setTranslationX(0.0f);
            ʼ(aVar.ॱ);
            this.ˋॱ.remove(size);
        }
        for (size = this.ʼ.size() - 1; size >= 0; size--) {
            ʻ((s) this.ʼ.get(size));
            this.ʼ.remove(size);
        }
        for (size = this.ͺ.size() - 1; size >= 0; size--) {
            s sVar = (s) this.ͺ.get(size);
            sVar.ˊ.setAlpha(1.0f);
            ॱˊ(sVar);
            this.ͺ.remove(size);
        }
        for (size = this.ॱˊ.size() - 1; size >= 0; size--) {
            ˊ((c) this.ॱˊ.get(size));
        }
        this.ॱˊ.clear();
        if (ॱ()) {
            int size2;
            ArrayList arrayList;
            int size3;
            for (size2 = this.ˎ.size() - 1; size2 >= 0; size2--) {
                arrayList = (ArrayList) this.ˎ.get(size2);
                for (size3 = arrayList.size() - 1; size3 >= 0; size3--) {
                    a aVar2 = (a) arrayList.get(size3);
                    View view2 = aVar2.ॱ.ˊ;
                    view2.setTranslationY(0.0f);
                    view2.setTranslationX(0.0f);
                    ʼ(aVar2.ॱ);
                    arrayList.remove(size3);
                    if (arrayList.isEmpty()) {
                        this.ˎ.remove(arrayList);
                    }
                }
            }
            for (size2 = this.ˋ.size() - 1; size2 >= 0; size2--) {
                arrayList = (ArrayList) this.ˋ.get(size2);
                for (size3 = arrayList.size() - 1; size3 >= 0; size3--) {
                    s sVar2 = (s) arrayList.get(size3);
                    sVar2.ˊ.setAlpha(1.0f);
                    ॱˊ(sVar2);
                    arrayList.remove(size3);
                    if (arrayList.isEmpty()) {
                        this.ˋ.remove(arrayList);
                    }
                }
            }
            for (size2 = this.ˏ.size() - 1; size2 >= 0; size2--) {
                arrayList = (ArrayList) this.ˏ.get(size2);
                for (size3 = arrayList.size() - 1; size3 >= 0; size3--) {
                    ˊ((c) arrayList.get(size3));
                    if (arrayList.isEmpty()) {
                        this.ˏ.remove(arrayList);
                    }
                }
            }
            ॱ(this.ᐝ);
            ॱ(this.ˊ);
            ॱ(this.ॱ);
            ॱ(this.ʽ);
            ᐝ();
        }
    }

    void ॱ(List<s> list) {
        for (int size = list.size() - 1; size >= 0; size--) {
            ((s) list.get(size)).ˊ.animate().cancel();
        }
    }

    public boolean ˋ(@NonNull s sVar, @NonNull List<Object> list) {
        return !list.isEmpty() || super.ˋ(sVar, list);
    }
}
